 /******************************************************************************
 * Name        : SingletonLazy.cpp
 * Author      : yinjianwen
 * Create      : 2018年3月23日
 * Version     :
 * Copyright   : Copyright © 1998 - 2017 Bluedon All Rights Reserved
 * description : C++, Ansi-style
 * function		: 
 *****************************************************************************/

#include <stdio.h>
#include "class.h"

SingletonLazy * SingletonLazy::m_pStLazy = NULL;
pthread_mutex_t SingletonLazy::mutex;

SingletonLazy* SingletonLazy::DoubleCheckGetInstance()
{
    pthread_mutex_init(&mutex, NULL);
    if (NULL == m_pStLazy) {
        pthread_mutex_lock(&mutex);
        if (NULL == m_pStLazy) {
            m_pStLazy = new SingletonLazy;
        } /* if end */
        pthread_mutex_unlock(&mutex);
    } /* if end */
    return m_pStLazy;
}
SingletonLazy * SingletonLazy::MeyersGetInstance()
{
    pthread_mutex_init(&mutex, NULL);
    pthread_mutex_lock(&mutex);
    static SingletonLazy ob_MeyersSt;
    pthread_mutex_unlock(&mutex);
    return &ob_MeyersSt;
}
void SingletonLazy::DestroySingleton()
{
    delete this->m_pStLazy;
    this->m_pStLazy = NULL;
}
int SingletonLazy::Add(int i, int j)
{
    return i + j;
}
SingletonLazy::SingletonLazy()
{

}
SingletonLazy::~SingletonLazy()
{
    pthread_mutex_destroy(&mutex);
}
